<!-- 电梯图片 -->

<template>
  <div class="DetailLiftVertical-MyImg">
    <img v-if="obj.props.door.value === '0'" :src="liftOpen" />
    <img v-else :src="liftClose" />

    <div>
      <i class="el-icon-caret-bottom" :class="{ 'DetailLiftVertical-MyImg-light': obj.props.runState.value === '2' }" />
      <span>{{ floorText }}</span>
      <i class="el-icon-caret-top" :class="{ 'DetailLiftVertical-MyImg-light': obj.props.runState.value === '1' }" />
    </div>
  </div>
</template>

<script>
// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import props from './props'

const getImg = (name) => CORE.common(`monitor/lift/${name}.png`)

// ============================== 导出组件 ============================== //

export default {
  /**
   * 名称定义 (实际使用名称)
   */
  name: 'MyImg',

  /**
   * 混入列表 (配置选项合并)
   */
  mixins: [CORE.mixWeb()],

  /**
   * 属性注册 (抽取以便查阅)
   */
  props,

  /**
   * 计算属性 (慎用箭头函数)
   */
  computed: {
    /**
     * 电梯关门
     */
    liftClose: () => getImg('lift-close'),

    /**
     * 电梯开门
     */
    liftOpen: () => getImg('lift-open'),

    /**
     * 楼层文本
     */
    floorText() {
      const floor = +this.obj.props.floor.value
      return floor < 0 || floor > 9 ? floor : `0${floor || 1}` // 若为 0 则显示为一层
    },
  },
}
</script>

<style lang="scss">
@import './index.scss';
</style>
